import QtQuick 2.0

Column {
    id: radioBtnGroup

    signal clicked(int btnIdx)
    property string button1: ""
    property string button2: ""
    property int textSize: 18
    property string textFont: "Verdana"
    property color textColor: "#FF000000"
    
    spacing: 10
    
    Row{
        id: row1
        spacing: 10
        Item {
            width: 10
            height: parent.height
        }
        Image {
            id: buttonImage1
            source: "images/radioButtonCheck.png"
            MouseArea {
                id: mouseRegion1
                anchors.fill: buttonImage1
                onClicked: { 
                    radioBtnGroup.clicked(0);
                    buttonImage1.source = "images/radioButtonCheck.png";
                    buttonImage2.source = "images/radioButtonUncheck.png";
                }
            }
        }
        Text {
            anchors.verticalCenter: buttonImage1.verticalCenter
            text: radioBtnGroup.button1
            font.family: radioBtnGroup.textFont
            font.pointSize: radioBtnGroup.textSize
            color: radioBtnGroup.textColor
        }
    }
    Row{
        id: row2
        spacing: 10
        Item {
            width: 10
            height: parent.height
        }
        Image {
            id: buttonImage2
            source: "images/radioButtonUncheck.png"
            MouseArea {
                id: mouseRegion2
                anchors.fill: buttonImage2
                onClicked: { 
                    radioBtnGroup.clicked(1);
                    buttonImage1.source = "images/radioButtonUncheck.png";
                    buttonImage2.source = "images/radioButtonCheck.png";
                }
            }
        }
        Text {
            anchors.verticalCenter: buttonImage2.verticalCenter
            text: radioBtnGroup.button2
            font.family: radioBtnGroup.textFont
            font.pointSize: radioBtnGroup.textSize
            color: radioBtnGroup.textColor
        }
    }


    function toggle( idx ) {
        radioBtnGroup.clicked(idx);
        switch( idx ) {
        case "0":
                buttonImage1.source = "images/radioButtonCheck.png";
                buttonImage2.source = "images/radioButtonUncheck.png";
                break;
        case "1":
                buttonImage1.source = "images/radioButtonUncheck.png";
                buttonImage2.source = "images/radioButtonCheck.png";
                break;
        }
    }
}
